import 'package:ccshop/ui/widget/refresh/RefreshableStatefulWidget.dart';
import 'package:flutter/material.dart';

class RefreshViewTest extends StatefulWidget {
  @override
  _RefreshViewTestState createState() => _RefreshViewTestState();
}

class _RefreshViewTestState extends State<RefreshViewTest> {
  String _content = "测试前";

  @override
  Widget build(BuildContext context) {
    RefreshableView _refresh = RefreshableView(
      builder: (context) {
        print('重建了RefreshableView');
        return Center(
          child: Text(_content),
        );
      },
    );
    return Scaffold(
      appBar: AppBar(title: Text("局部刷新测试"),),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          _refresh,
          Builder(
            builder: (context){
              print('重建了btn');
              return RaisedButton(
                child: Text("点击刷新"),
                onPressed: (){
                  _content = "测试后";
                  _refresh.reload();
                },
              );
            },
          ),
          Builder(
            builder: (context){
              print('重建了btn2');
              return RaisedButton(
                child: Text("刷新整个页面"),
                onPressed: (){
                  setState(() {
                    _content = "刷新了整个页面";
                  });
                },
              );
            },
          ),
        ],
      ),
    );
  }
}
